package com.woniuxy.main.service.imp;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.woniuxy.main.mapper.UserMapper;
import com.woniuxy.main.pojo.Follow;
import com.woniuxy.main.pojo.User;
import com.woniuxy.main.service.UserService;

import lombok.Data;

@Transactional
@Service
@Data
public class UserServiceImp implements UserService{
	
	@Resource
	private UserMapper userMapper;

	@Override
	public int addUserByMail(User user) {
		return userMapper.addUserByMail(user);
	}

	@Override
	public int addUserByPhone(User user) {
		return userMapper.addUserByPhone(user);
	}
	
	@Override	//检查用户账户余额
	public double balanceCheck(int uid) {
		return userMapper.balanceCheck(uid);
	}

	@Override
	public int addUserByAccount(User user) {
		return userMapper.addUserByAccount(user);
	}

	@Override
	public User selectByAccount(String account) {
		return userMapper.selectByAccount(account);
	}

	@Override
	public User selectByMail(String umail) {
		return userMapper.selectByMail(umail);
	}

	@Override
	public User selectByPhone(String uphone) {
		return userMapper.selectByPhone(uphone);
	}

	@Override
	public User selectByUid(int uid) {
		return userMapper.selectByUid(uid);
	}

	@Override
	public void addUserHeadImage(User user) {
		userMapper.addUserHeadImage(user);
	}
		
	public int updateUser(User user) {
		return userMapper.updateUser(user);
	}

	
	@Override	//查询当前用户关注的人--关注
	public List<User> findFollowed(int uid) {
		return userMapper.findFollowed(uid);
	}

	@Override	//查询关注当前用户的人--粉丝
	public List<User> findFans(int uid) {
		return userMapper.findFans(uid);
	}

	@Override	//查询和当前用户相互关注的人--好友
	public List<User> findFriend(int uid) {
		return userMapper.findFriend(uid);
	}

	@Override	//取消关注
	public int cancleFollow(Follow follow) {
		return userMapper.cancleFollow(follow);
	}

	@Override	//新增关注
	public int addFollow(Follow follow) {
		return userMapper.addFollow(follow);
	}

	@Override	//校验我是否已关注ta
	public Follow checkFollow(Follow follow) {
		return userMapper.checkFollow(follow);
	}

	@Override
	public int lockAccount(Map<String, Object> request) {
		return userMapper.lockAccount(request);
	}

	@Override
	public int unLockAccount(int uid) {
		return userMapper.unLockAccount(uid);
	}

	@Override
	public String isPhoneExist(String uphone) {
		return userMapper.isPhoneExist(uphone);
	}

	@Override
	public String isMailExist(String umail) {
		return userMapper.isMailExist(umail);
	}

	@Override
	public int adminAddCoach(User user) {
		return userMapper.adminAddCoach(user);
	}
	
	@Override	//通过用户名查找用户
	public User findUserByUid(User user) {
		return userMapper.findUserByUid(user);
	}

	@Override
	public int refuseComplain(int cpid) {
		return userMapper.refuseComplain(cpid);
	}

	@Override
	public int aceptComplain(int cpid) {
		return userMapper.aceptComplain(cpid);
	}
	
	@Override
	public String isAccountExist(String account) {
		return userMapper.isAccountExist(account);
	}

	@Override //更改密码
	public int changePwd(String pwd, int uid) {
		return userMapper.changePwd(pwd, uid);
	}
	
	@Override
	public int setPwd(User user) {
		return userMapper.setPwd(user);
	}

}
